package com.syf.kit.config;

import com.syf.kit.SyfJacksonCont;
import com.syf.kit.SyfJsonMapper;
import com.syf.kit.SyfJsonMapperFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(SyfJacksonConfiguration.class)
public class SyfJacksonAutoConfig {

    @Bean(name = SyfJacksonCont.DEFAULT_BEAN_NAME_OF_JSON_MAPPER)
    SyfJsonMapper buildDefaultJsonMapper(SyfJacksonConfiguration configuration) {
        return new SyfJsonMapper(configuration.isIgnoreNull(), configuration.isIgnoreUnknownFields());
    }

    @Bean
    SyfJsonMapperFactory buildSyfJsonMapperFactory(SyfJacksonConfiguration configuration) {
        return new SyfJsonMapperFactory(configuration.isIgnoreNull(), configuration.isIgnoreUnknownFields());
    }

}
